#include <iostream>

using namespace std;

const int MAX = 1000000 + 1;
const int maxP = 10001;
int isp[MAX], p[MAX], fact[MAX];
int idx = 0;
long long ans = 0;

int main() {
    //init prime
    for (int i = 0; i < MAX; i++) isp[i] = 1;
    for (int i = 2; i < MAX; i++) {
        if (isp[i]) {
            p[idx++] = i;
            for (int j = i + i; j < MAX; j += i) {
                isp[j] = 0;
            }
        }
    }

    for (int i = 2; i < MAX; i++) {
        //1. check how many prime factors
        idx = 0;
        int pp = i;
        for (int j = 0; j < MAX; j++) {
            if (isp[pp] || pp == 1) {
                break;
            }
            if (pp % p[j] == 0) {
                fact[idx++] = p[j];
                while (pp % p[j] == 0) {
                    pp /= p[j];
                }
            }
        }
        if (pp != 1 && isp[pp]) fact[idx++] = pp;

        int n = idx;
        ans += i;
        for (int j = 1; j < (1<<n); j++) {
           int product = 1;
           int count = 0;
           for (int k = 0; k < n; k++) {
               if ((1<<k) & j) 
                   product *= fact[k], count++;
           }
           int add = i / product;
           if (count & 1) add = -add;
           ans += add;
        }
    }
    
    cout << ans << endl;

    return 0;
}
